﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Drawing;

namespace FontTool
{
    public abstract class command
    {
        public abstract void Execute(nFont font);
        public abstract void Undo(nFont font);
        public abstract void Redo(nFont font);
    }

    class spaceCommand : command
    {
        private float previousValue;
        private float newValue;

        public spaceCommand(float current, float value)
        {
            previousValue = current;
            newValue = value;
        }

        public override void Execute(nFont font)
        {
            font._Space = newValue;
            Console.WriteLine(@"spaceCommand\Execute: " + newValue);
        }

        public override void Undo(nFont font)
        {
            font._Space = previousValue;
            Console.WriteLine(@"spaceCommand\Undo: " + previousValue);
        }

        public override void Redo(nFont font)
        {
            font._Space = newValue;
            Console.WriteLine(@"spaceCommand\Redo: " + newValue);
        }
    }

    class kerningCommand : command
    {
        private float previousValue;
        private float newValue;

        public kerningCommand(float current, float value)
        {
            previousValue = current;
            newValue = value;
        }

        public override void Execute(nFont font)
        {
            font._Kerning = newValue;
            Console.WriteLine(@"kerningCommand\Execute: " + newValue);
        }

        public override void Undo(nFont font)
        {
            font._Kerning = previousValue;
            Console.WriteLine(@"kerningCommand\Undo: " + previousValue);
        }

        public override void Redo(nFont font)
        {
            font._Kerning = newValue;
            Console.WriteLine(@"kerningCommand\Redo: " + newValue);
        }
    }

    class xheightCommand : command
    {
        private float previousValue;
        private float newValue;

        public xheightCommand(float current, float value)
        {
            previousValue = current;
            newValue = value;
        }

        public override void Execute(nFont font)
        {
            font._xHeight = newValue;
            Console.WriteLine(@"xheightCommand\Execute: " + newValue);
        }

        public override void Undo(nFont font)
        {
            font._xHeight = previousValue;
            Console.WriteLine(@"xheightCommand\Undo: " + previousValue);
        }

        public override void Redo(nFont font)
        {
            font._xHeight = newValue;
            Console.WriteLine(@"xheightCommand\Redo: " + newValue);
        }
    }

    class capheightCommand : command
    {
        private float previousValue;
        private float newValue;

        public capheightCommand(float current, float value)
        {
            previousValue = current;
            newValue = value;
        }

        public override void Execute(nFont font)
        {
            font._capHeight = newValue;
            Console.WriteLine(@"capheightCommand\Execute: " + newValue);
        }

        public override void Undo(nFont font)
        {
            font._capHeight = previousValue;
            Console.WriteLine(@"capheightCommand\Undo: " + previousValue);
        }

        public override void Redo(nFont font)
        {
            font._capHeight = newValue;
            Console.WriteLine(@"capheightCommand\Redo: " + newValue); 
        }
    }

    class ascenderHeightCommand : command
    {
        private float previousValue;
        private float newValue;

        public ascenderHeightCommand(float current, float value)
        {
            previousValue = current;
            newValue = value;
        }

        public override void Execute(nFont font)
        {
            font._ascenderHeight = newValue;
            Console.WriteLine(@"ascenderHeightCommand\Execute: " + newValue); 
        }

        public override void Undo(nFont font)
        {
            font._ascenderHeight = previousValue;
            Console.WriteLine(@"ascenderHeightCommand\Undo: " + previousValue);
        }

        public override void Redo(nFont font)
        {
            font._ascenderHeight = newValue;
            Console.WriteLine(@"ascenderHeightCommand\Redo: " + newValue); 
        }
    }

    class leadingCommand : command
    {
        private float previousValue;
        private float newValue;

        public leadingCommand(float current, float value)
        {
            previousValue = current;
            newValue = value;
        }

        public override void Execute(nFont font)
        {
            font._Leading = newValue;
            Console.WriteLine(@"leadingCommand\Execute: " + newValue); 
        }

        public override void Undo(nFont font)
        {
            font._Leading = previousValue;
            Console.WriteLine(@"leadingCommand\Undo: " + previousValue); 
        }

        public override void Redo(nFont font)
        {
            font._Leading = newValue;
            Console.WriteLine(@"leadingCommand\Redo: " + newValue); 
        }
    }

    class descenderHeightCommand : command
    {
        private float previousValue;
        private float newValue;

        public descenderHeightCommand(float current, float value)
        {
            previousValue = current;
            newValue = value;
        }

        public override void Execute(nFont font)
        {
            font._descenderHeight = newValue;
            Console.WriteLine(@"descenderHeightCommand\Execute: " + newValue); 
        }

        public override void Undo(nFont font)
        {
            font._descenderHeight = previousValue;
            Console.WriteLine(@"descenderHeightCommand\Undo: " + previousValue);  
        }

        public override void Redo(nFont font)
        {
            font._descenderHeight = newValue;
            Console.WriteLine(@"descenderHeightCommand\Redo: " + newValue); 
        }
    }
}
